<%@ page language="java" import="java.util.*, java.text.*,com.zjut.zs.util.tools.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*, com.zjut.an.util.module.*,
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,com.zjut.zs.applyview.manager.*, com.zjut.zs.applyview.dao.*,
com.zjut.zs.userinfo.manager.*, com.zjut.zs.userinfo.dao.*,com.zjut.an.config.manager.*, com.zjut.an.config.dao.*,
com.zjut.zs.exampage.manager.*, com.zjut.zs.exampage.dao.*" pageEncoding="utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">  
<meta name="renderer" content="webkit"> 
<title>无标题文档</title>
<script src="css/tailwindcss.css"></script>
<script src='../plugins/assets/plugins/jquery-3.5.1.min.js'></script>
<script src="js/jquery.qrcode-0.6.0.min.js"></script>
<script src="js/jquery-migrate-1.2.1.min.js"></script>

</head>
<style type="text/css">
	ul{display:block;margin:0;padding:0;list-style:none;}
	li{display:block;margin:0;padding:0;list-style: none;}
	.place{height:40px; background:url(images/righttop.gif) repeat-x;}
	.place span{line-height:40px; font-weight:bold;float:left; margin-left:12px;}
	.placeul li{float:left; line-height:40px; padding-left:7px; padding-right:12px; background:url(images/rlist.gif) no-repeat right;}
	.placeul li:last-child{background:none;}
</style>
<body>
<jsp:include page="zs_uservalidate.jsp" flush="true"/>
<%
if (session.getAttribute("zsUser") == null&&session.getAttribute("admin") == null&&session.getAttribute("user") == null) {
	out.print("<script>alert('由于长时间未操作，系统已经自动注销，请重新登陆');</script>");
	out.print("<script>top.window.location='main.jsp';</script>");
} else {

AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
ZsHTMLCreat html = (ZsHTMLCreat) SpringContextUtil.getBean("ZsHTMLCreat");
ZsUserStatusManager usmanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");
ZsUserinfoManager uimanager = (ZsUserinfoManager) SpringContextUtil.getBean("ZsUserinfoManager");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");
ZsExamPageManager epmanager = (ZsExamPageManager) SpringContextUtil.getBean("ZsExamPageManager");
ZsApplyViewManager amanager = (ZsApplyViewManager) SpringContextUtil.getBean("ZsApplyViewManager");

ZsUser user = null;
if(session.getAttribute("admin")!=null && request.getParameter("usId")!=null) {
	String usId = request.getParameter("usId");
	user = umanager.getData(usId);
} else if (session.getAttribute("zsUser")!=null) {
	user = (ZsUser)session.getAttribute("zsUser");	
} 

ZsUserinfo userinfo = new ZsUserinfo();
if (user!=null) {
	userinfo.setZsUser(user);
	userinfo = (ZsUserinfo)uimanager.getDataByInstance(1,1,null,null,userinfo).getObjects().get(0);
}
ZsApplyView appview = amanager.getData(user.getUsId());
String key = MD5.toMD5(appview.getUssId().toString());
ZsExamPage exampage = new ZsExamPage();
exampage.setExType("测试通知单");
PageModule pagemodule = epmanager.getDataByInstance(1,1,null,null,exampage);
if(pagemodule.getTotal()>0){
	exampage = (ZsExamPage)pagemodule.getObjects().get(0);
}
 %>
	<div class="max-w-8xl mx-auto px-4 py-6">
	<%if (null!=exampage.getExId()) {%>
		<button id="button" onclick="onprint()" class="flex items-center px-8 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors duration-200 text-xl ml-auto">打印</button>
	<%}%>
		<div id="container" class="container mx-auto" style="width:1000px;margin:0 auto;display:flex;justify-content:center;">
    <%

    if (null!=exampage.getExId()) {
    	String content = exampage.getExContent().replace("$usName$", appview.getUsName())
    			.replace("$usIdcard$", html.getInputString(appview.getUsIdcard()))
    	    	.replace("$usEmail$", html.getInputString(appview.getUsEmail()))
    	    	.replace("$usMobile$", html.getInputString(appview.getUsMobile()))
    	    	.replace("$testNo$", html.getInputString(appview.getTestNo()))
    	    	.replace("$column1$", html.getInputString(appview.getColumn1()))
    	    	.replace("$column2$", html.getInputString(appview.getColumn2()))
    	    	.replace("$column3$", html.getInputString(appview.getColumn3()))
    	    	.replace("$column4$", html.getInputString(appview.getColumn4()))
    	    	.replace("$column5$", html.getInputString(appview.getColumn5()))
    	    	.replace("$column6$", html.getInputString(appview.getColumn6()))
    	    	.replace("$column7$", html.getInputString(appview.getColumn7()))
    	    	.replace("$column8$", html.getInputString(appview.getColumn8()))
    	    	.replace("$column9$", html.getInputString(appview.getColumn9()))
    	    	.replace("$column10$", html.getInputString(appview.getColumn10()))
    	    	.replace("$inZydm01$", html.getInputString(appview.getInZydm01()))
    	    	.replace("$inZydm02$", html.getInputString(appview.getInZydm02()))
    	    	.replace("$inZydm03$", html.getInputString(appview.getInZydm03()))
    	    	.replace("$inZydm04$", html.getInputString(appview.getInZydm04()))
    	    	.replace("$inZydm05$", html.getInputString(appview.getInZydm05()))
    	    	.replace("$inZydm06$", html.getInputString(appview.getInZydm06()))
    	    	.replace("$inZydm07$", html.getInputString(appview.getInZydm07()))
    	    	.replace("$inZydm08$", html.getInputString(appview.getInZydm08()))
    	    	.replace("$inZydm09$", html.getInputString(appview.getInZydm09()))
    	    	.replace("$inZydm10$", html.getInputString(appview.getInZydm10()))
    	    	.replace("$inZymc01$", html.getInputString(appview.getInZymc01()))
    	    	.replace("$inZymc02$", html.getInputString(appview.getInZymc02()))
    	    	.replace("$inZymc03$", html.getInputString(appview.getInZymc03()))
    	    	.replace("$inZymc04$", html.getInputString(appview.getInZymc04()))
    	    	.replace("$inZymc05$", html.getInputString(appview.getInZymc05()))
    	    	.replace("$inZymc06$", html.getInputString(appview.getInZymc06()))
    	    	.replace("$inZymc07$", html.getInputString(appview.getInZymc07()))
    	    	.replace("$inZymc08$", html.getInputString(appview.getInZymc08()))
    	    	.replace("$inZymc09$", html.getInputString(appview.getInZymc09()))
    	    	.replace("$inZymc10$", html.getInputString(appview.getInZymc10()))
    	    	.replace("$scColumn1$", html.getInputString(appview.getScColumn1()))
    	    	.replace("$scColumn2$", html.getInputString(appview.getScColumn2()))
    	    	.replace("$scColumn3$", html.getInputString(appview.getScColumn3()))
    	    	.replace("$scColumn4$", html.getInputString(appview.getScColumn4()))
    	    	.replace("$scColumn5$", html.getInputString(appview.getScColumn5()))
    	    	.replace("$scColumn6$", html.getInputString(appview.getScColumn6()))
    	    	.replace("$scColumn7$", html.getInputString(appview.getScColumn7()))
    	    	.replace("$scColumn8$", html.getInputString(appview.getScColumn8()))
    	    	.replace("$scColumn9$", html.getInputString(appview.getScColumn9()))
    	    	.replace("$scColumn10$", html.getInputString(appview.getScColumn10()))
    	    	.replace("$inXb$", html.getInputString(appview.getInXb()))
    	    	.replace("$inMz$", html.getInputString(appview.getInMz()))
    	    	.replace("$inZzmm$", html.getInputString(appview.getInZzmm()))
    	    	.replace("$usBmxh$", html.getInputString(appview.getUsBmxh())) 
    	    	.replace("$inKslb$", html.getInputString(appview.getInKslb()))
    	    	.replace("$inLxdh2$", html.getInputString(appview.getInLxdh2()))
    	    	.replace("$inByxxmc$", html.getInputString(appview.getInByxxmc()))
    	    	.replace("$testNoOrder$", html.getInputString(appview.getInPinying()))
    	    	.replace("$receiveno$", user.getUsNo());
    	content = content.replace("src=\"inPhoto\"", "src='../photo/"+html.getInputString(user.getUsIdcard())+".jpg' ");   		
	    out.print(content);
    } else {
    	out.print("尚未发布测试通知单");
    }
    %>
		</div>
	</div>
<script>
	$("#ewcode1").attr("src","https://sapi.k780.com/?app=qr.get&data=<%=anconfig.getSingleConfigInfoByName("网站域名") %>/admin/zsApplyViewStatus.jsp?usId=<%=user.getUsId()%>&level=L&size=6&localStatusType=single");
	$("#ewcode2").attr("src","https://sapi.k780.com/?app=qr.get&data=<%=anconfig.getSingleConfigInfoByName("网站域名") %>/admin/zsApplyViewEdit.jsp?usId=<%=user.getUsId()%>&level=L&size=6");

function printHtml(html) {
	var bodyHtml = document.body.innerHTML;
	document.body.innerHTML = html;
	window.print();
	document.body.innerHTML = bodyHtml;
}
function onprint() {
	var html = $("#container").html();
	printHtml(html);

	// 打印时向后台提交打印记录
	$.ajax({
	cache: false,
	type: "GET",
	url:'../zsUserPrintPublic.action?ussId=<%=appview.getUssId()%>&key=<%=key%>&randnum='+Math.floor(Math.random()*1000000),
	data: {},
	dataType: "json",
	async: false,
	error: function(request) {
	console.log("打印记录提交失败");
},
	success: function(data) {
	console.log("打印记录提交成功");
}
});
}

</script>
<%} %>
</body>
</html>
